﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var paystatusData = Jxstar.findComboData('paystatus');
	var authtypeData = Jxstar.findComboData('authtype');
	var moneytypeData = Jxstar.findComboData('moneytype');

	var cols = [
	{col:{header:'付款计划状态', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: paystatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: paystatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < paystatusData.length; i++) {
				if (paystatusData[i][0] == value)
					return paystatusData[i][1];
			}
		}}, field:{name:'contract_pay__plan_status',type:'string'}},
	{col:{header:'合同编号', width:100, sortable:true}, field:{name:'contract_pay__contract_code',type:'string'}},
	{col:{header:'合同名称', width:211, sortable:true}, field:{name:'contract_pay__contract_name',type:'string'}},
	{col:{header:'立项批复金额(万元)', width:133, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__project_money',type:'float'}},
	{col:{header:'合同金额(万元)', width:119, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__contract_money',type:'float'}},
	{col:{header:'已付款金额(万元)', width:117, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__pay_money',type:'float'}},
	{col:{header:'本月计划付款(万元)', width:126, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__plan_money',type:'float'}},
	{col:{header:'*公司核准付款(万元)', width:145, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__check_money',type:'float'}},
	{col:{header:'*本次付款依据', width:193, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.TextField({
			maxLength:500, allowBlank:false
		})}, field:{name:'contract_pay__pay_cause',type:'string'}},
	{col:{header:'合同付款条款', width:144, sortable:true}, field:{name:'contract_pay__contract_condition',type:'string'}},
	{col:{header:'决算审定金额(万元)', width:120, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__cost_money',type:'float'}},
	{col:{header:'账面欠款(万元)', width:100, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'contract_pay__last_money',type:'float'}},
	{col:{header:'付款进度%（包含本次）', width:77, sortable:true, renderer:JxUtil.formatNumber(2)}, field:{name:'contract_pay__pay_ratio',type:'float'}},
	{col:{header:'收款单位', width:142, sortable:true}, field:{name:'contract_pay__provider_name',type:'string'}},
	{col:{header:'授权方式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: authtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: authtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < authtypeData.length; i++) {
				if (authtypeData[i][0] == value)
					return authtypeData[i][1];
			}
		}}, field:{name:'contract_pay__auth_type',type:'string'}},
	{col:{header:'项目编码', width:100, sortable:true}, field:{name:'contract_pay__project_code',type:'string'}},
	{col:{header:'项目名称', width:198, sortable:true}, field:{name:'contract_pay__project_name',type:'string'}},
	{col:{header:'项目类别', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'contract_pay__money_type',type:'string'}},
	{col:{header:'项目负责人', width:73, sortable:true}, field:{name:'contract_pay__project_user',type:'string'}},
	{col:{header:'实施单位', width:138, sortable:true}, field:{name:'contract_pay__dept_name',type:'string'}},
	{col:{header:'合同签订日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract_pay__write_date',type:'date'}},
	{col:{header:'计划月份', width:90, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m') : '';
		}}, field:{name:'contract_pay__plan_month',type:'date'}},
	{col:{header:'申请日期', width:80, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract_pay__apply_date',type:'date'}},
	{col:{header:'申请人', width:55, sortable:true}, field:{name:'contract_pay__apply_user',type:'string'}},
	{col:{header:'申请单号', width:100, sortable:true}, field:{name:'contract_pay__pay_code',type:'string'}},
	{col:{header:'申请人ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__apply_userid',type:'string'}},
	{col:{header:'合同ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__contract_id',type:'string'}},
	{col:{header:'实施单位ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__dept_id',type:'string'}},
	{col:{header:'项目负责人ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__project_userid',type:'string'}},
	{col:{header:'收款单位ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__provider_id',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__pay_id',type:'string'}},
	{col:{header:'项目ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__project_id',type:'string'}},
	{col:{header:'合同签约部门', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__done_deptname',type:'string'}},
	{col:{header:'合同签约部门ID', width:100, sortable:true, hidden:true}, field:{name:'contract_pay__done_deptid',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '0',
		funid: 'pay_plansub'
	};
	
	config.eventcfg = {			pattach: function() {			var records = this.grid.getSelectionModel().getSelections();			if (!JxUtil.selectone(records)) return;						var self = this;			var keyid = records[0].get('contract_pay__project_id');						var params = 'projectid=' + keyid + '&funid=pay_plansub';			params += '&pagetype=grid&eventcode=pattach';			//发送请求，取相关附件ID			Request.postRequest(params, function(data){JxPm.showAttach(data, 'pay_plansub', keyid);});		}	};	config.initpage = function(gridNode) {		var getMainGrid = function(g){			var tab = g.ownerCt.ownerCt;			return tab.getComponent(0).getComponent(0);		};				//点击保存刷新主表记录		var grid = gridNode.page;		var event = gridNode.event;		event.on('aftersave', function(ge) {			var pgrid = getMainGrid(ge.grid);			pgrid.getStore().reload();		});				//主表已复核的记录不能编辑		grid.on('beforeedit', function(ge) {			var pgrid = getMainGrid(ge.grid);			var records = pgrid.getSelectionModel().getSelections();						var s = records[0].get('contract_mpay__auditing');	//记录状态值			if (s == null || s.length == 0) s = '0';			//if (s != '0' && s != '6') return false;			if (s == '3') return false;						return true;		});	};
		
	return new Jxstar.GridNode(config);
}